package aiku.numericalcontroloa.Controller.FinanceManagement;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Dto.FinanceManagement.AccountDto;
import aiku.numericalcontroloa.Model.Dto.FinanceManagement.IncomeExpenditureDetailDto;
import aiku.numericalcontroloa.Service.FinanceManagement.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 账户控制层
 * @Author 黄广庭
 * @Date 2024/5/7 12:02
 */
@RestController
@RequestMapping("/account")
@Slf4j
public class AccountController {

    private final AccountService accountService;

    public AccountController(AccountService accountService) {
        this.accountService = accountService;
    }

    /**
     * 添加账户
     * @param accountDto
     * @return
     */
    @PostMapping("/addAccount")
    public Result addAccount(@RequestBody AccountDto accountDto){
        return accountService.addAccount(accountDto);
    }

    /**
     * 修改账户信息
     * @param accountDto
     * @return
     */
    @PostMapping("/updateAccount")
    public Result updateAccount(@RequestBody AccountDto accountDto){
        return accountService.updateAccount(accountDto);
    }

    /**
     * 获取账户列表，含收支
     * 可根据开户名和账号模糊查询
     * 可统计年月日收支
     * @param accountDto
     * @return
     */
    @PostMapping("/getAccountDetailList")
    public Result getAccountDetailList(@RequestBody AccountDto accountDto){
        return accountService.getAccountDetailList(accountDto);
    }

    /**
     * 获取单个账户信息，不含收支
     * @param accountDto
     * @return
     */
    @PostMapping("/getAccount")
    public Result getAccount(@RequestBody AccountDto accountDto){
        return accountService.getAccount(accountDto);
    }

    /**
     * 获取账号列表，不含收支
     * 可根据开户名和账户模糊查询
     * @param accountDto
     * @return
     */
    @PostMapping("/getAccountList")
    public Result getAccountList(@RequestBody AccountDto accountDto){
        return accountService.getAccountList(accountDto);
    }

    /**
     * 删除账户
     * @param accountDto
     * @return
     */
    @PostMapping("/deleteAccount")
    public Result deleteAccount(@RequestBody AccountDto accountDto){
        return accountService.deleteAccount(accountDto);
    }

    /**
     * 获取账户明细列表
     * @param detailDto
     * @return
     */
    @PostMapping("/getDetailList")
    public Result getAccountIncomeExpenditureDetailList(@RequestBody IncomeExpenditureDetailDto detailDto){
        return accountService.getAccountIncomeExpenditureDetailList(detailDto);
    }

    /**
     * 修改备注
     * @param detailDto
     * @return
     */
    @PostMapping("/updateDetailRemark")
    public Result updateDetailRemark(@RequestBody IncomeExpenditureDetailDto detailDto){
        return accountService.updateDetailRemark(detailDto);
    }
}
